package com.whmskj.xjlhbc.vo;

import cn.hutool.core.util.NumberUtil;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Data
public class HomeVo {

    private Top top = new Top();

    private Chart cldbChart = new Chart();

    private Chart clqxChart = new Chart();

    private List<Cqxx> cqxx = new ArrayList<>();

    private List<Integer> sbzt = new ArrayList<>();

    private List<Map<String, Object>> gzlx = new ArrayList<>();

    private List<Stop> stop = new ArrayList<>();

    private BottomChart clqsChart = new BottomChart();

    private BottomChart nhqsChart = new BottomChart();


    @Data
    public static class Top{
        private TopBoard by = new TopBoard();
        private TopBoard sy = new TopBoard();
    }

    @Data
    public static class TopBoard{
        private String count1;
        private String count2;
        private String count3;
        private String count4;
        private String count5;
        private String count6;
    }

    @Data
    public static class Chart{
        private List<String> xAxisData = new ArrayList<>();
        private List<String> data = new ArrayList<>();
        private List<List<Double>> value = new ArrayList<>();
    }

    @Data
    public static class Cqxx{
        private int total;

        private int cq;

        private int qq;

        private int xx;

        private int lz;
        private List<Map<String, Object>> list = new ArrayList<>();
    }

    @Data
    public static class Stop{
        private String name;

        private String total;

        private String dwt;

        private String cwt;

        private String jt;

        private String qt;
    }

    @Data
    public static class BottomChart{
        private List<String> data = new ArrayList<>();
        private List<Double> value = new ArrayList<>();
    }

    public List<Stop> getStop() {
        Stop stop1 = stop.get(1);
        stop1.setTotal(convertSeconds(stop1.getTotal()));
        stop1.setDwt(convertSeconds(stop1.getDwt()));
        stop1.setCwt(convertSeconds(stop1.getCwt()));
        stop1.setJt(convertSeconds(stop1.getJt()));
        stop1.setQt(convertSeconds(stop1.getQt()));
        return stop;
    }

    private static String convertSeconds(String val) {
        int seconds = NumberUtil.parseInt(val, 0);
        int hours = Math.floorDiv(seconds, 3600);
        int minutes = Math.floorDiv(seconds % 3600, 60);
        int remainingSeconds = seconds % 60;
        return String.format("%02d:%02d:%02d", hours, minutes, remainingSeconds);
    }
}
